package com.qingcheng.exception;

import com.qingcheng.util.ObjectUtil;

/**
 * @author lin.jia
 */
public class ThrowBusinessException {

    /**
     * 直接抛出异常
     *
     * @param message 消息
     */
    public static void throwBusinessException(String message) {
        throw new BusinessException(message);
    }

    /**
     * 根据true false 决定是否抛出异常
     *
     * @param message 消息
     * @param b       结果
     */
    public static void isTrue(Boolean b, String message) {
        if (b) {
            throw new BusinessException(message);
        }
    }


    /**
     * 如果对象们不为空
     *
     * @param objects 对象
     */
    public static void isNotNulls(String message, Object... objects) {
        if (ObjectUtil.isNotNulls(objects)) {
            throw new BusinessException(message);
        }
    }


    /**
     * 如果对象们为空
     *
     * @param objects 对象
     */
    public static void isNulls(String message, Object... objects) {
        if (ObjectUtil.isNulls(objects)) {
            throw new BusinessException(message);
        }
    }
}
